package main

import "fmt"

func minCostClimbingStairs(cost []int) int {
	//最终最低花费
	minCost := 0
	//总的楼梯数量
	count := len(cost) + 1
	//爬上第i个楼梯的最低总花费
	dp := make([]int, count)
	//并且初始位置0楼或者1楼的花费为0
	dp[0] = 0
	dp[1] = 0
	//开始遍历数组，找到最低花费
	for i := 2; i < count; i++ {
		//如何处理先从0楼还是先从1楼开始上呢
		dp[i] = min(dp[i-1]+cost[i-1], dp[i-2]+cost[i-2])
		minCost = dp[i]
	}
	return minCost
}

func main() {
	costs := []int{10, 15, 20}
	fmt.Println(minCostClimbingStairs(costs))
}
